import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

public class HJ94 {

        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);

            while (scanner.hasNext()){
                int size = Integer.parseInt(scanner.nextLine());
                Map<String,Integer> map  = new LinkedHashMap<>();
                String inputLine = scanner.nextLine();
                String[] line = inputLine.split(" ");

                for (int i = 0; i < size; i++) {
                    map.put(line[i], 0);
                }
                scanner.nextLine();
                inputLine = scanner.nextLine();
                line = inputLine.split(" ");

                int count = 0;
                for (String item: line) {
                    if(map.containsKey(item)){
                        map.put(item, map.get(item) + 1);
                    }else{
                        count++;
                    }
                }

                for (String key: map.keySet()) {
                    System.out.println(key + " : " + map.get(key));
                }

                System.out.println("Invalid : " + count);
            }
        }
}
